package com.daohang361.imqq.ui;

import java.awt.Canvas;
import java.awt.Component;
import java.awt.Container;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.Toolkit;
import javax.swing.GroupLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.SwingConstants;

/** 
 * @author naner E-mail:likun3344@163.com 
 * @create time：2011-4-24 下午11:18:21 
 */
public class CeckCodeFrameBak extends BaseFrame {

	private static final long serialVersionUID = 231799735987911883L;
	public CeckCodeFrameBak() {
		super();
        initComponents();
        this.setResizable(true);
	}
	  private void initComponents() {
		  setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    		JLabel calv_label = new JLabel(); 
    		JLabel label1 = new JLabel("安全中心发现您的账号存在异常。为保护您的账号安全,本");
    		JLabel label11 = new JLabel("次登陆需要输入验证字符，这可以防止恶意程序的自动登陆");
    		JLabel label2=new javax.swing.JLabel("<html><font>异常原因:</font></html>");
    		JLabel label3=new javax.swing.JLabel(
"<html>本次登陆地点异常<a style='TEXT-DECORATION:none' href=\"http://im.qq.com/help/safe/about-validate.shtml#a14 \">参考详情及解除异常</a></html>");
    		JLabel label4=new javax.swing.JLabel("<html><font>验证码:</font></html>");
    		JTextField textField1 = new JTextField();
    		JLabel label5=new javax.swing.JLabel("<html><font>看不清,换一张:</font></html>");
    		JButton subButton = new JButton("确定");
    		JButton cancerButton = new JButton("取消");
		    Canvas canvas1= new CheckImg("temp/158507684check.png",130,60);
		    calv_label.add(canvas1);
		    Container c = getContentPane();
		    GroupLayout layout = new GroupLayout(c);
		    c.setLayout(layout);
		    
		    //自动设定组件、组之间的间隙
		    layout.setAutoCreateGaps(true);
		    layout.setAutoCreateContainerGaps(true);

		    //水平
		    GroupLayout.ParallelGroup hpg2a = layout.createParallelGroup(GroupLayout.Alignment.LEADING);
		    hpg2a.addComponent(label1);
		    hpg2a.addComponent(label11);
		    hpg2a.addComponent(label2);
		    hpg2a.addComponent(label3);
		    hpg2a.addComponent(label4);
		    hpg2a.addComponent(textField1);
		    GroupLayout.ParallelGroup hpg2b = layout.createParallelGroup(GroupLayout.Alignment.LEADING);
		    hpg2b.addComponent(calv_label).addComponent(label5);
		  
		    GroupLayout.ParallelGroup hpg2c = layout.createParallelGroup(GroupLayout.Alignment.TRAILING);
		    hpg2c.addComponent(subButton).addComponent(cancerButton);
		    GroupLayout.ParallelGroup hpg = layout.createParallelGroup(GroupLayout.Alignment.TRAILING);
		    hpg.addGroup(hpg2a);
		    hpg.addGroup(hpg2b);
		    hpg.addGroup(hpg2c);
		    layout.setHorizontalGroup(layout.createSequentialGroup()
		    		.addGroup(hpg));   
		    layout.linkSize(SwingConstants.HORIZONTAL,new Component[] { subButton, cancerButton });
		    //垂直
		    GroupLayout.ParallelGroup vpg2 = layout.createParallelGroup(GroupLayout.Alignment.LEADING);
		    vpg2.addComponent(calv_label);
		    vpg2.addComponent(label5);
		    GroupLayout.ParallelGroup vpg3 = layout.createParallelGroup(GroupLayout.Alignment.TRAILING);
		    vpg3.addComponent(subButton);
		    vpg3.addComponent(cancerButton);
		    layout.setVerticalGroup(layout.createSequentialGroup()
		    		.addComponent(label1).addComponent(label11).addComponent(label2).addComponent(label3).
			    	 addComponent(label4).addComponent(textField1).addGroup(vpg2).addGroup(vpg3));
		    
		    setLocation(200,200);
		    pack();
		    setVisible(true);
	  }
	  
	
	  public static void main(String a[]){
		  new CeckCodeFrameBak();
	  }
	  
	  class CheckImg extends Canvas{
		private static final long serialVersionUID = 1882866880950754864L;
		private int width;
		private int higth;
		Toolkit tool;
		Image myimage;  
	    public CheckImg(String filename, int width, int higth) {
			this.width = width;
			this.higth = higth;
			setSize(width, higth);
			tool = getToolkit();
			Image image = Toolkit.getDefaultToolkit().getImage(filename);
			myimage = image.getScaledInstance(width,higth, Image.SCALE_SMOOTH); 
		}
	    
	    public void paint(Graphics g) {
			g.drawImage(myimage, 0, 0, width, higth, this);
		}
	  }
}
